<?php


namespace app\common\validate;


use think\Validate;

class Article extends Validate
{
    //全局验证规则
    protected $rule = [
        'title|文章标题' => 'require|unique:article',
        'author|作者' => 'require',
        'tags|标签' => 'require',
        'cate_id|所属栏目' => 'require',
        'desc|文章概要' => 'require',
        'content|文章内容' => 'require',
        'is_top|推荐' => 'require'
    ];

    //添加验证场景
    public function sceneAdd()
    {
        return $this->only(['title','author','tags','cateid','desc','content']);
    }

    //推荐操作验证场景
    public function sceneTop()
    {
        return $this->only(['is_top']);
    }

    //文章编辑验证场景
    public function sceneEdit()
    {
        return $this->only(['title','tags','cate_id','desc','content','is_top']);
    }
}